package org.aaron.wbclient.utils;

import java.net.URLDecoder;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class HttpUtils {
	/**
	 * 将指定的参数集合进行URL转码
	 * @param decodeNames 指定参数集合
	 * @param map  转码后存储Map集合
	 * @return
	 */
	public static Map<String, String> decodeByDecodeNames(List<String> decodeNames, Map<String, String> map) {
		Iterator<Entry<String, String>> it = map.entrySet().iterator();
		while (it.hasNext()) {
			Entry<String, String> entry = it.next();
			for (String decodeName : decodeNames) {
				if (entry.getKey().equals(decodeName)) {
					entry.setValue(URLDecoder.decode(entry.getValue()));
					map.put(entry.getKey(), entry.getValue());
				}
			}
		}
		return map;
	}
}
